#include "StdAfx.h"
#include "client.hpp"
#include "cln_rtt_handler.h"
#include "cln_reg_handler.h"
#include "cln_move_handler.h"
#include "cln_login_handler.h"

using namespace fly::jld::client;

void setup_cln(cln_handler* hnd)
{

	try
	{
		// Initialise the client.
		string srv_address = "172.22.71.125";
		//LOG_NOTICE("Please enter the adress of the server you want to connect:");
		//cin>>srv_address;
		size_t cln_num;
		LOG_NOTICE("Please enter the num of the cln you want to connect:");
		cin>>cln_num;
		client cln(hnd, 4, srv_address,"55555", cln_num);

		//Run the cln until stopped.
		cln.run();

	}
	catch (std::exception& e)
	{
		LOG_T_ERR(e.what());
	}
}

TEST(cln, reg)
{
	cln_handler* hnd = new cln_reg_handler(true);
	hnd->set_next(new cln_rtt_handler())->set_next(new cln_move_handler());
	setup_cln(hnd);
}

TEST(cln, login)
{
	cln_handler* hnd = new cln_login_handler(true);
	hnd->set_next(new cln_rtt_handler())->set_next(new cln_move_handler());
	setup_cln(hnd);
}

TEST(cln, rtt)
{
	cln_handler* hnd = new cln_reg_handler(true);
	hnd->set_next(new cln_rtt_handler(true))->set_next(new cln_move_handler());
	setup_cln(hnd);
}

TEST(cln, move)
{
	cln_handler* hnd = new cln_reg_handler(true);
	hnd->set_next(new cln_rtt_handler(true))->set_next(new cln_move_handler(true));
	setup_cln(hnd);
}